package com.ysd.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnore;

//用户
@Entity
public class Users {

	@Id 
	private String Id;//用户编号
	private String LoginName;//登陆用户名
	private String Password;//密码 
	private String IsLockout;//是否锁定
	  
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date LastLoginTime;//最后一次登录时间
	private int PsdWrongTime;//密码错误次数
	
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date LockTime;//锁定时间
	private String ProtectEMail;//密保邮箱
	private String protectMTel;//密保手机号
	
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date CreateTime;//账户创立时间
	
	//多对多 一个用户有多个角色，一个角色又对应多个用户
	@ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
	@JoinTable(
			name = "userroles",//中间表的名称
			joinColumns = {@JoinColumn(name="UserId")},//维护方的外键
			inverseJoinColumns = {@JoinColumn(name="RoleId")}
	)
	private List<Roles> Roles;

	public Users() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Users(String id, String loginName, String password, String isLockout, Date lastLoginTime, int psdWrongTime,
			Date lockTime, String protectEMail, String protectMTel, Date createTime, List<com.ysd.entity.Roles> roles) {
		super();
		Id = id;
		LoginName = loginName;
		Password = password;
		IsLockout = isLockout;
		LastLoginTime = lastLoginTime;
		PsdWrongTime = psdWrongTime;
		LockTime = lockTime;
		ProtectEMail = protectEMail;
		this.protectMTel = protectMTel;
		CreateTime = createTime;
		Roles = roles;
	}

	@Override
	public String toString() {
		return "Users [Id=" + Id + ", LoginName=" + LoginName + ", Password=" + Password + ", IsLockout=" + IsLockout
				+ ", LastLoginTime=" + LastLoginTime + ", PsdWrongTime=" + PsdWrongTime + ", LockTime=" + LockTime
				+ ", ProtectEMail=" + ProtectEMail + ", protectMTel=" + protectMTel + ", CreateTime=" + CreateTime
				+ ", Roles=" + Roles + "]";
	}

	public String getId() {
		return Id;
	}

	public void setId(String id) {
		Id = id;
	}

	public String getLoginName() {
		return LoginName;
	}

	public void setLoginName(String loginName) {
		LoginName = loginName;
	}

	public String getPassword() {
		return Password;
	}

	public void setPassword(String password) {
		Password = password;
	}

	public String getIsLockout() {
		return IsLockout;
	}

	public void setIsLockout(String isLockout) {
		IsLockout = isLockout;
	}

	public Date getLastLoginTime() {
		return LastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		LastLoginTime = lastLoginTime;
	}

	public int getPsdWrongTime() {
		return PsdWrongTime;
	}

	public void setPsdWrongTime(int psdWrongTime) {
		PsdWrongTime = psdWrongTime;
	}

	public Date getLockTime() {
		return LockTime;
	}

	public void setLockTime(Date lockTime) {
		LockTime = lockTime;
	}

	public String getProtectEMail() {
		return ProtectEMail;
	}

	public void setProtectEMail(String protectEMail) {
		ProtectEMail = protectEMail;
	}

	public String getProtectMTel() {
		return protectMTel;
	}

	public void setProtectMTel(String protectMTel) {
		this.protectMTel = protectMTel;
	}

	public Date getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Date createTime) {
		CreateTime = createTime;
	}

	public List<Roles> getRoles() {
		return Roles;
	}

	public void setRoles(List<Roles> roles) {
		Roles = roles;
	}
	



}
